﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dm.Domain.Entities;
//using MySql.Data.MySqlClient;
using Dm.Domain.CrossCutting;

namespace Dm.Domain.Repository.EntityRepositories.ActiveRecord
{
    public class StudentActiveRecord //: IStudentRepository
    {
        public const string MySqlConnectionString = "Data Source=localhost;Database=ARPAMIS;Uid=root;Pwd=DarkMASTERJAY14;";
        public StudentActiveRecord()
        {
           
        }

        public List<Student> RetrieveAll(bool includeInactive)
        {
            throw new NotImplementedException();
            //MySqlConnection mysqlConnection = new MySqlConnection(MySqlConnectionString);
            //using (mysqlConnection)
            //{
            //    mysqlConnection.Open();
            //    string query = string.Format("SELECT * FROM Students WHERE StatusId = {0}", Settings.Statuses.ActiveStatus);
            //    MySqlCommand command = new MySqlCommand(query,mysqlConnection);
            //    List<Student> students = new List<Student>();
            //    MySqlDataReader rd = command.ExecuteReader();
            //    while (rd.Read())
            //    {
            //        Student student = new Student();
            //        student.FirstName = rd["FirstName"].ToString() ?? "";
            //        student.MiddleName = rd["MiddleName"].ToString() ?? "";
            //        student.LastName = rd["LastName"].ToString() ?? "";
            //        student.ControlNumber = rd["StudentNumber"].ToString() ?? "";
            //        student.ContactNumber = rd["ContactNumber"].ToString() ?? "";
            //        student.Email = rd["Email"].ToString() ?? "";
            //        student.EntityId = int.Parse(rd["StudentId"].ToString());
            //        student.AddressId = int.Parse(rd["AddressId"].ToString());
            //        student.YearLevel = int.Parse(rd["YearLevel"].ToString());
            //        students.Add(student);
            //    }

            //    mysqlConnection.Close();
            //    return students;
                
            //}
        }

        public List<Student> SearchAllParameter(string firstName, string middleName, string lastName, string studentNumber, string email, string contactNumber, string address, bool includeInactive = false)
        {
            throw new NotImplementedException();

            //There is still lot of work to be done here. Which will be somewhere in optimization phase/maintenance phase :D

            //MySqlConnection mysqlConnection = new MySqlConnection(MySqlConnectionString);
            //using (mysqlConnection)
            //{
            //    mysqlConnection.Open();
            //    string query = string.Format("SELECT * FROM Students WHERE FirstName = '{1}' AND MiddleName = '{2}' AND LastName = '{3}' AND StudentNumber = '{4}' And Email = '{5}' AND StatusId = {0}", 
            //        Settings.Statuses.ActiveStatus,
            //        firstName,middleName,lastName,studentNumber,email);
            //    MySqlCommand command = new MySqlCommand(query, mysqlConnection);
            //    List<Student> students = new List<Student>();
            //    MySqlDataReader rd = command.ExecuteReader();
            //    while (rd.Read())
            //    {
            //        Student student = new Student();
            //        student.FirstName = rd["FirstName"].ToString() ?? "";
            //        student.MiddleName = rd["MiddleName"].ToString() ?? "";
            //        student.LastName = rd["LastName"].ToString() ?? "";
            //        student.ControlNumber = rd["StudentNumber"].ToString() ?? "";
            //        student.ContactNumber = rd["ContactNumber"].ToString() ?? "";
            //        student.Email = rd["Email"].ToString() ?? "";
            //        student.EntityId = int.Parse(rd["StudentId"].ToString());
            //        student.AddressId = int.Parse(rd["AddressId"].ToString());
            //        student.YearLevel = int.Parse(rd["YearLevel"].ToString());
            //        students.Add(student);
            //    }

            //    mysqlConnection.Close();
            //    return students;

            //}
        }

        public List<Student> SearchByName(string firstName, string middleName, string lastName)
        {
            throw new NotImplementedException();
        }

        public Student Retrieve(int id)
        {
            throw new NotImplementedException();
        }

        public List<Student> Retrieve()
        {
            throw new NotImplementedException();
        }

        public Student Create(Student entity)
        {
            throw new NotImplementedException();
        }

        public void Update(Student entity)
        {
            throw new NotImplementedException();
        }

        public void Delete(Student entity)
        {
            throw new NotImplementedException();
        }

        public void Delete(int id)
        {
            throw new NotImplementedException();
        }


        public Student RetrieveWithDetails(int id, bool includeAddress = false, bool includeStatus = false)
        {
            throw new NotImplementedException();
        }
    }
}
